package service.impl;

import dao.UserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pojo.User;
import service.Userservice;

import java.security.PrivateKey;
import java.util.List;
@Service("userservice")
public class UserServiceimpl implements Userservice {
    @Autowired
    private UserDao userDao;
    public int addUser(User user){
        return userDao.addUser(user);
    }
    public List<User> findAll(User user, int offset, int pageSize){
        //TODO
        List<User> users = userDao.findAll(user, offset, pageSize);
        return users;
    }
    public User findById(Integer id){
        return userDao.findById(id);
    }

    @Override
    public int UpdateUser(User user) {
        return userDao.UpdateUser(user);
    }

    @Override
    public int DeleteUserById(Integer id) {
        return userDao.DeleteUserById(id);
    }

    @Override
    public int count(User user) {
        return userDao.count(user);
    }

    @Override
    public boolean login(User user) {
        int count =userDao.login(user);
        if(count>0)
        {
            return true;
        }
        return false;
    }
}
